<?php
class Boot
{

    function __construct()
    {
        UrlRewrite::rewrite();
        Boot::addFilter("render", "SSO");
        Boot::addFilter("render", "DefaultRender");

    }

    public function start()
    {
        $access = new Access($_GET['controller'], $_GET['method']);
        $access->route();
    }


    public static function addFilter($filterType, $filterName)
    {
        $filters = $GLOBALS['filter'];
        if (array_key_exists($filterType, $filters)) {
            array_push($GLOBALS['filter'][$filterType], $filterName);
        }
        else
        {
            //如果是支持的过滤器
            if (in_array($filterType, $GLOBALS['config']['filter_position'])) {
                $GLOBALS['filter'][$filterType] = array();
                array_push($GLOBALS['filter'][$filterType], $filterName);
            }
            else {
                throw new ErrorException("unKnow filterName");
            }
        }
    }

    public static function redirect($url)
    {
        header("location:$url");
        die();
    }

}

?>